<?php if (!defined('THINK_PATH')) exit();?>
<!DOCTYPE html>
<html>
<head>
<title>云平台</title>
<meta content="" name="keywords">
<meta content="" name="description">
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<link href="<?php echo C('BOOTSTRAP');?>css/bootstrap.min.css?v=<?php echo C('VERSION');?>" rel="stylesheet" type="text/css" />
<link href="<?php echo C('LAYERUI');?>css/layui.css?v=<?php echo C('VERSION');?>" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="<?php echo C('HOME_JS');?>jquery-2.0.3.min.js"></script>
<script language="JavaScript" src="<?php echo C('LAYERUI');?>layui.js"></script>
<script language="JavaScript" src="<?php echo C('HOME_JS');?>function.js"></script>
</head>
<body>
<style>
	.first_nav,.second_nav{
		position:relative;
		top:2px;
	}
	.pointer{
		cursor:pointer;
		font-weight:normal;
	}
</style>
<table class="table table-bordered">
  <tr class="active">
  	<th>编号</th><th>一级菜单</th><th>二级菜单</th>
  </tr>
  <?php if(is_array($menus)): $i = 0; $__LIST__ = $menus;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr>
  	<td><?php echo ($vo["id"]); ?></td><td><input type="checkbox" class="first_nav pointer parent_<?php echo ($vo["id"]); ?>" data_id="<?php echo ($vo["id"]); ?>" id="input_<?php echo ($vo["id"]); ?>" <?php if(($vo["status"]) == "1"): ?>checked<?php endif; ?>> <label for="input_<?php echo ($vo["id"]); ?>" class="pointer"><?php echo ($vo["name"]); ?></label></td><td></td>
  </tr>
  <?php if(is_array($vo["child_menu"]["child_menu"])): $i = 0; $__LIST__ = $vo["child_menu"]["child_menu"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo_child): $mod = ($i % 2 );++$i;?><tr>
  	<td><?php echo ($vo_child["id"]); ?></td><td align="center">|--</td><td><input type="checkbox"  class="second_nav pointer child_<?php echo ($vo["id"]); ?> child_<?php echo ($vo_child["id"]); ?>" parent_id="<?php echo ($vo["id"]); ?>" data_id="<?php echo ($vo_child["id"]); ?>" id="input_<?php echo ($vo_child["id"]); ?>" <?php if(($vo_child["status"]) == "1"): ?>checked<?php endif; ?>> <label for="input_<?php echo ($vo_child["id"]); ?>" class="pointer"><?php echo ($vo_child["name"]); ?></label></td>
  </tr><?php endforeach; endif; else: echo "" ;endif; endforeach; endif; else: echo "" ;endif; ?>
</table>
<script>
	$('.table').on('click','.first_nav',function(){
		var check = this.checked;
		var data_id=$(this).attr('data_id');
		if(check){
			var status=1;
			$('.child_'+data_id).prop('checked',true);
		}else{
			var status=0;
			$('.child_'+data_id).prop('checked',false);
		}
		var group_id="<?php echo ($group_id); ?>";
		var data={status:status,data_id:data_id,group_id:group_id};
		var url="<?php echo U('Ajax/update_quanxian1');?>";
		$.post(url,data);
		
	})
	$('.table').on('click','.second_nav',function(){
		var check = this.checked;
		var data_id=$(this).attr('data_id');
		var parent_id=$(this).attr('parent_id');
		if(check){
			var status=1;
			$('.parent_'+parent_id).prop('checked',true);
		}else{
			var status=0;
			var obj_check = $('.child_'+parent_id+':checked').length;
			if(obj_check<=0){
				$('.parent_'+parent_id).prop('checked',false);
			}
		}
		var group_id="<?php echo ($group_id); ?>";
		var data={status:status,data_id:data_id,group_id:group_id};
		var url="<?php echo U('Ajax/update_quanxian2');?>";
		$.post(url,data);
	})
</script>
</body>
</html>